﻿using System;
using System.Windows.Input;
using System.Windows;
using System.Windows.Controls;

namespace SQLDataTransferer.Controls.Behaviours
{
    public static class ComboBoxBehaviours
    {
        #region EventCommands

        public static readonly DependencyProperty SelectionChangedCommand =
            EventBehaviourFactory.CreateCommandExecutionEventBehaviour(ComboBox.SelectionChangedEvent,
                                                                        "SelectionChangedCommand",
                                                                        typeof(ComboBoxBehaviours));

        public static readonly DependencyProperty LostFocusCommand =
            EventBehaviourFactory.CreateCommandExecutionEventBehaviour(ComboBox.LostFocusEvent,
                                                                        "LostFocusCommand",
                                                                        typeof(ComboBoxBehaviours));

        public static readonly DependencyProperty TextChangedCommand =
            EventBehaviourFactory.CreateCommandExecutionEventBehaviour(ComboBox.KeyUpEvent,
                                                                        "TextChangedCommand",
                                                                        typeof(ComboBoxBehaviours));
        #endregion

        #region CommandHandlers

        #region SelectionChanged

        // SelectionChanged
        public static void SetSelectionChangedCommand(DependencyObject o, ICommand value)
        {
            o.SetValue(SelectionChangedCommand, value);
        }

        public static ICommand GetSelectionChangedCommand(DependencyObject o)
        {
            return o.GetValue(SelectionChangedCommand) as ICommand;
        }

        #endregion

        #region LostFocus

        // LostFocus
        public static void SetLostFocusCommand(DependencyObject o, ICommand value)
        {
            o.SetValue(LostFocusCommand, value);
        }

        public static ICommand GetLostFocusCommand(DependencyObject o)
        {
            return o.GetValue(LostFocusCommand) as ICommand;
        }

        #endregion

        #region TextChanged

        // TextChanged
        public static void SetTextChangedCommand(DependencyObject o, ICommand value)
        {
            o.SetValue(TextChangedCommand, value);
        }

        public static ICommand GetTextChangedCommand(DependencyObject o)
        {
            return o.GetValue(TextChangedCommand) as ICommand;
        }

        #endregion

        #endregion
    }
}
